package com.industry.system;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.rules.DateType;
import com.industry.system.dal.dataobject.BaseEntity;

public class MybatisGenerator {
    public static void main(String[] args) {
        FastAutoGenerator.create("jdbc:mysql://47.109.139.26:3306/industry?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&autoReconnect=true", "root", "hxindustry")
                .globalConfig(builder -> {
                    builder.author("nbZhuoZh")
                            .dateType(DateType.TIME_PACK) // 设置作者
//                            .outputDir("C:\\Users\\Cheuk\\Desktop\\hx-backend\\industry-system\\src\\main\\java"); // 指定输出目录
                             .outputDir("C:\\Users\\Cheuk\\Desktop\\hx-backend"); // 指定输出目录
                })
                .packageConfig(builder ->
                        builder.parent("com.industry.product.dal.dataobject") // 设置父包名
                )
                .strategyConfig(builder ->
                                builder.addInclude("examinaion_bank,examinaion_paper,examinaion_paper_answer,examinaion_paper_question,examinaion_question") // 设置需要生成的表名
//                    .addTablePrefix("sys_") // 设置过滤表前缀
                                        .entityBuilder()
                                        .enableFileOverride()
                                        .superClass(BaseEntity.class)
                                        .addSuperEntityColumns("id", "create_user", "create_time", "update_user", "update_time")
                                        .enableLombok()
                                        .logicDeleteColumnName("del_flag")
                )
                .strategyConfig(builder ->
                        builder.controllerBuilder()
                                .disable()
                )
                .strategyConfig(builder ->
                        builder.serviceBuilder()
                                .disable()
                )
                .strategyConfig(builder ->
                        builder.mapperBuilder()
                                .enableFileOverride()
                                .superClass(BaseMapper.class)
                                .enableMapperAnnotation()
                                .disableMapperXml()
                )
                .execute();
    }
}
